package com.leetcode.algorithm.y22.m09.w4;

import java.util.Arrays;

/**
 * 506. 相对名次
 * 
 * https://leetcode.cn/problems/relative-ranks/
 * 
 * @author jie.deng
 *
 */
class Question0506Solution01 {

	public String[] findRelativeRanks(int[] score) {
		int len = score.length;
		int[][] arr = new int[len][2];
		for (int i = 0; i < len; i++) {
			arr[i] = new int[] { score[i], i };
		}
		Arrays.sort(arr, (arr1, arr2) -> arr2[0] - arr1[0]);
		String[] result = new String[len];
		String[] strs = new String[] { "Gold Medal", "Silver Medal", "Bronze Medal" };
		for (int i = 0; i < len; i++) {
			int[] nums = arr[i];
			result[nums[1]] = (i >= 3 ? "" + (i + 1) : strs[i]);
		}
		return result;
	}

}